package net.uzen.office.attached.dao;

import java.util.ArrayList;
import java.util.List;

import net.uzen.office.article.model.Article;
import net.uzen.office.attached.model.Attached;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class AttachedDaoImpl extends SqlMapClientDaoSupport implements
		AttachedDao {

	@Override
	public int createAttached(Attached attached) {
		int attachedNo = (Integer) getSqlMapClientTemplate().insert(
				"attached.createAttached", attached);
		return attachedNo;
	}

	@Override
	public boolean deleteAttached(Attached attached) {
		int result = getSqlMapClientTemplate().delete("attached.deleteAttached",
				attached);
		return result > 0 ? true : false;
	}

	@Override
	public Attached getAttached(Attached attached) {
		return (Attached) getSqlMapClientTemplate().queryForObject(
				"attached.getAttached", attached);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Attached> getAttachedList(Article article) {
		return (ArrayList<Attached>) getSqlMapClientTemplate().queryForList(
				"attached.getAttachedList", article);
	}

	@Override
	public boolean modifyAttached(Attached attached) {
		int result = getSqlMapClientTemplate().update("attached.modifyAttached",
				attached);
		return result > 0 ? true : false;
	}

}
